home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / x / text.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-04  |  2.6 KB  |  124 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4.  
  5.    This is part of the X user-interface for the WAIS software.  Do with it
  6.    as you please.
  7.  
  8.    jonathan@Think.COM
  9. */
  10.  
  11. /* Copyright (c) CNIDR (see ../COPYRIGHT) */
  12.  
  13.  
  14. /*
  15.  * $Log: text.c,v $
  16.  * Revision 1.2  1994/08/05  07:27:19  pfeifer
  17.  * Release beta 04
  18.  *
  19.  * Revision 1.1  1993/02/16  15:10:18  freewais
  20.  * Initial revision
  21.  *
  22.  * Revision 1.1  92/06/15  13:44:05  jonathan
  23.  * Initial revision
  24.  * 
  25.  */
  26.  
  27. #include "xwais.h"
  28.  
  29. TextList
  30. NewText()
  31. {
  32.   TextList result;
  33.  
  34.   if(NULL != (result = (TextList) s_malloc(sizeof(_TextList)))) {
  35.     if(NULL == (result->thisText = (Textbuff) s_malloc(sizeof(_Textbuff)))) {
  36.       s_free(result);
  37.       result = NULL;
  38.     }
  39.     else {
  40.       result->thisText->shell = NULL;
  41.       result->thisText->textwindow = NULL;
  42.       result->thisText->status = NULL;
  43.       result->thisText->docid = NULL;
  44.       result->thisText->text = NULL;
  45.       result->thisText->type = NULL;
  46.       result->thisText->size = 0;
  47.       result->nextText = allText;
  48.       allText = result;
  49.     }
  50.   }
  51.   return(result);
  52. }
  53.  
  54. void
  55. KillText(t)
  56. Textbuff t;
  57. {
  58.   TextList a_tList, tmp;
  59.  
  60.   if(t != NULL) {
  61.     if(t->shell != NULL) XtDestroyWidget(t->shell);
  62.     if(t->text != NULL) s_free(t->text);
  63.     if(t->type != NULL) s_free(t->type);
  64.     for(a_tList = allText; a_tList != NULL; a_tList = a_tList->nextText)
  65.       if(a_tList->thisText == t) {
  66.     if(a_tList->nextText != NULL) {
  67.       a_tList->thisText = a_tList->nextText->thisText;
  68.       tmp = a_tList->nextText;
  69.       a_tList->nextText = a_tList->nextText->nextText;
  70.       s_free(tmp);
  71.     }
  72.     else {
  73.       a_tList->thisText = NULL;
  74.       if(a_tList == allText) {
  75.         s_free(a_tList);
  76.         allText = NULL;
  77.       }
  78.     }
  79.     break;
  80.       }
  81.     s_free(t);
  82.   }
  83. }
  84.  
  85. Textbuff
  86. findText(w)
  87. Widget w;
  88. {
  89.   TextList a_tList;
  90.   static Widget shell = NULL;
  91.  
  92.   if (w != NULL) 
  93.     if((shell = XtParent(w)) != NULL)
  94.       shell = XtParent(shell);
  95.   if (shell != NULL) {
  96.     for(a_tList = allText; a_tList != NULL; a_tList = a_tList->nextText)
  97.       if(a_tList->thisText->shell != NULL)
  98.       if (a_tList->thisText->shell == shell)
  99.         return a_tList->thisText;
  100.   }
  101.   return NULL;
  102. }
  103.  
  104. Textbuff
  105. findTextDoc(doc, type)
  106. DocumentID doc;
  107. char *type;
  108. {
  109.   TextList a_tList;
  110.  
  111.   if (doc != NULL) { 
  112.     for(a_tList = allText; a_tList != NULL; a_tList = a_tList->nextText)
  113.       if(a_tList->thisText != NULL &&
  114.      a_tList->thisText->docid == doc) {
  115.     if(a_tList->thisText->type != NULL &&
  116.        type != NULL  &&
  117.        !strcmp(a_tList->thisText->type, type))
  118.       return (a_tList->thisText);
  119.       }
  120.   }
  121.   return NULL;
  122. }
  123.  
  124.